package com.resou.reader.signin;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.resou.reader.R;

public class SignInRuleItemDecoration extends RecyclerView.ItemDecoration {
    private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    private int mDrawSize;

    SignInRuleItemDecoration(Context context,int drawSize) {
        mDrawSize = drawSize;
        mPaint.setStyle(Paint.Style.STROKE);
        mPaint.setStrokeWidth(context.getResources().getDimension(R.dimen.qb_px_2));
        mPaint.setColor(0x808a8a8a);
    }

    @Override
    public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
        super.onDraw(c, parent, state);
        float left = parent.getPaddingStart();
        float right = parent.getWidth() - parent.getPaddingEnd();
        for (int i = 0; i < mDrawSize; i++) {
            View view = parent.getChildAt(i);
            float top = view.getBottom();
            c.drawLine(left, top, right, top, mPaint);
        }
    }
}
